package com.dews.course.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Collections;
import java.util.List;

/**
 * @author 清风学Java
 * @version 1.0.0
 * @date 2025/2/4
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum SemesterEnum {

    /**
     * 第一学期：ONE
     * 第二学期：TWO
     * 第三学期：THREE
     * 第四学期：FOUR
     * 第五学期：FIVE
     * 第六学期：SIX
     * 第七学期：SEVEN
     * 第八学期：EIGHT
     */
    ONE("第一学期", 1, List.of(2, 3, 4)),
    TWO("第二学期", 2, List.of(2, 3, 4)),
    THREE("第三学期", 3, List.of(2, 3, 4)),
    FOUR("第四学期", 4, List.of(2, 3, 4)),
    FIVE("第五学期", 5, List.of(3, 4)),
    SIX("第六学期", 6, List.of(3, 4)),
    SEVEN("第七学期", 7, List.of(4)),
    EIGHT("第八学期", 8, List.of(4));

    private String semester;
    private Integer semesterId;

    /**
     * 学期适合的学制集合
     */
    private List<Integer> educationalSystem;

    /**
     * 根据学制返回学期枚举集合
     */
    public static List<SemesterEnum> getSemesterEnumList(Integer educationalSystem) {
        return switch (educationalSystem) {
            case 2 -> List.of(ONE, TWO, THREE, FOUR);
            case 3 -> List.of(ONE, TWO, THREE, FOUR, FIVE, SIX);
            case 4 -> List.of(ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT);
            default -> Collections.emptyList();
        };
    }

}
